package com.example.smartcity_poverty.ui.AllService.VolunteerService.adapter

import android.content.Intent
import android.text.Html
import com.example.smartcity_poverty.App.Companion.url
import com.example.smartcity_poverty.Base.BaseRecyclerAdapter
import com.example.smartcity_poverty.logic.ServiceBean.VolunteerService.VtHomeNewsModel
import com.example.smartcity_poverty.logic.util.Util.glide
import com.example.smartcity_poverty.ui.AllService.VolunteerService.activity.VtShowNewsActivity
import kotlinx.android.synthetic.main.re_vt_home_one_news.*

/**
 *  created by ikun
 *  ANDROID STUDIO - version 4.0
 *  email: jinkunwei41@gmail.com
 * --------------------------------
 *
 **/
class VtHomeOneNewsAdapter(
    val list: MutableList<VtHomeNewsModel.RowsBean>,
    layoutId: Int
) : BaseRecyclerAdapter<VtHomeNewsModel.RowsBean>(list, layoutId) {
    override fun setData(
        view: BaseViewHolder.ViewFind,
        data: VtHomeNewsModel.RowsBean,
        position: Int,
        holder: BaseViewHolder
    ) {
        val d = list[position]
        val fv = holder.viewFind
        val con = holder.viewFind.view?.context

        glide(url + d.imgUrl, fv.vtHomeOneImage)
        fv.vtHomeOneTitle.text = d.title
        fv.vtHomeOneContent.text = d.summary

        holder.itemView.setOnClickListener {
            con?.startActivity(
                Intent(con, VtShowNewsActivity::class.java).putExtra(
                    "id",
                    d.id.toString()
                )
            )
        }
    }
}